﻿using Stee.CAP8.MessageBus.Sagas.Core.Sagas;
using Stee.CAP8.MessageBus.Sagas.Core.Sagas.SagaData;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;

namespace Stee.CAP8.MessageBus.Sagas.Order.Sagas.Data
{
    public class OrderSagaData : BaseSagaData
    {

        public OrderSagaData(string sagaId) : base(sagaId) 
        {

        }

      

        #region private fileds
        private bool orderCreated;
        private bool orderPaymented;
        private bool orderStockAdjusted;
        #endregion

        /// <summary>
        /// 订单是否创建
        /// </summary>
        public bool OrderCreated
        {
            get => orderCreated;
            set
            {
                if (orderCreated != value)
                {
                    orderCreated = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 支付是否完成
        /// </summary>
        public bool OrderPaymented
        {
            get => orderPaymented;

            set
            {

                if (orderPaymented != value)
                {
                    orderPaymented = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 库存是否调整
        /// </summary>
        public bool OrderStockAdjusted
        {
            get => orderStockAdjusted;

            set
            {
                if (orderStockAdjusted != value)
                {

                    orderStockAdjusted = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// saga是否完毕
        /// </summary>
        /// <returns></returns>
        public override bool IsDone()
        {
            base.LoadData();
            return OrderCreated && OrderPaymented && OrderStockAdjusted;
        }
    }


}
